﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace KTSonline.administrator
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["logout"] != null)
                Session["admin"] = null;
        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            KTSonlineDataContext db = new KTSonlineDataContext();
            var rs = db.ADMINs.Where(c => c.username == Login1.UserName.ToLower() && c.password == Login1.Password);
            if (rs.Count() == 0)
            {
                e.Authenticated = false;
                return;
            }
            e.Authenticated = true;
            Session["admin"] = rs.First();
        }

        protected void Login1_LoggedIn(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx");
        }
    }
}
